/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mock.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import mock.dto.AccountDTO;
import mock.utility.Utility;

public class WithdrawLimitDAOImp implements WithdrawLimitDAO {

		
	private Utility utility = new Utility();
	private AccountDAO accDAO = new AccountDAOImp();
	
	/**
	 * input: wdid
	 * output: wd limit value
	 */
    public double getWithdrawLimitByWDID(int wdid) {
       Connection con = utility.createConnection();
       if(con != null){
    	   PreparedStatement ps = null;
    	   ResultSet rs = null;
    	   try {
			ps = con.prepareStatement("select * from WithDrawLimit where WDID = ?");
			ps.setInt(1, wdid);
			rs = ps.executeQuery();
			if(rs.next()){
				double value = rs.getDouble("Value");
				return value;
			}else{
				return -1;
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return -1;
		}
      }else{
    	  return -1;
      }
    }
}
